package com.cn.cxq.bean;

import java.lang.reflect.InvocationTargetException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.apache.commons.beanutils.DynaBean;
import org.apache.commons.beanutils.ResultSetDynaClass;
import org.springframework.beans.BeanUtils;
import org.springframework.jdbc.support.rowset.ResultSetWrappingSqlRowSet;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;



@Component
@Transactional
public class DBTest extends BasicBean{

	public String dbtest(Connection con) throws SQLException, IllegalAccessException, InvocationTargetException  {
		String sql = " select * from gr_user_";
		String userName = null;
		try {
			List<User> lists = new ArrayList<User>();
			PreparedStatement stmt = con.prepareStatement(sql);
			ResultSet rs = stmt.executeQuery();
			ResultSetDynaClass rsdc = new ResultSetDynaClass(rs);
			Iterator<?> rows = rsdc.iterator();
			while (rs.next()) {
				 User user = new User();
				 DynaBean row = (DynaBean) rows.next();
				 BeanUtils.copyProperties(user, row);
				 lists.add(user);
			}
		} finally {
			con.close();
		}
		return userName;

	}
}
